<%@ page language="java" contentType="text/html; charset=utf-8"
    pageEncoding="utf-8"%>
    <%
	String path = request.getContextPath();
	String basePath = request.getScheme() + "://" + request.getServerName() + ":" + request.getServerPort()
			+ path + "/";
%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<link rel="stylesheet" type="text/css" href="../js/themes/default/easyui.css">
<link rel="stylesheet" type="text/css" href="../js/themes/icon.css">
<script type="text/javascript" src="../js/jquery.min.js" charset="utf-8"></script>
<script type="text/javascript" src="../js/jquery.easyui.min.js"charset="utf-8"></script>
<script type="text/javascript" src="../js/locale/easyui-lang-zh_CN.js"charset="utf-8"></script>
<title>凭证详情</title>
<script type="text/javascript">
$(function(){
	var lsh =  $("#i1").val();
	var das ="";
	 $.ajax({
           type: "GET",
           url:'<%=path%>/main/get/pzinfo',
		   data : {
					 "cropid":<%=session.getAttribute("cropid")%>,
					 "serialno":lsh,
					 "zhuangtai":"0"
				},
					async : false,
					success : function(data) {
						var data = eval('(' + data + ')');
					    var num = data.status;
					    if (num == 0) {
							    das=data.data;
							    
							    
							    $("#pzbh").val(das.serialno);
							    $("#zdrq").val(das.cdate);
							    $("#djs").val(das.djsum);
							
							    $("#zdren").val(das.zdname);
					   }

					}
				}); 
	    
	 var datagrid; //定义全局变量datagrid
     var editRow = undefined; //定义全局变量：当前编辑的行
	 
     datagrid=	$('#tt').datagrid({
			width:968,
			height:350,
		    url:'<%=path%>/main/get/pzinfos',
		    queryParams : {
		    	 "cropid":<%=session.getAttribute("cropid")%>,
				 "serialno":lsh,
				 "zhuangtai":"0"
			},
		    selectOnCheck: true,
			checkOnSelect: true,
			
		       toolbar: [
              
                { text: '修改', iconCls: 'icon-edit', handler: function () {
                    //修改时要获取选择到的行
                    var rows = datagrid.datagrid("getSelections");
                    //如果只选择了一行则可以进行修改，否则不操作
                    if (rows.length == 1) {
                        //修改之前先关闭已经开启的编辑行，当调用endEdit该方法时会触发onAfterEdit事件
                        if (editRow != undefined) {
                            datagrid.datagrid("endEdit", editRow);
                        }
                        //当无编辑行时
                        if (editRow == undefined) {
                            //获取到当前选择行的下标
                            var index = datagrid.datagrid("getRowIndex", rows[0]);
                            //开启编辑
                            datagrid.datagrid("beginEdit", index);
                            //把当前开启编辑的行赋值给全局变量editRow
                            editRow = index;
                            //当开启了当前选择行的编辑状态之后，
                            //应该取消当前列表的所有选择行，要不然双击之后无法再选择其他行进行编辑
                            datagrid.datagrid("unselectAll");
                        }
                    }
                }
                }, '-',
                { text: '保存', iconCls: 'icon-save', handler: function () {
                    //保存时结束当前编辑的行，自动触发onAfterEdit事件如果要与后台交互可将数据通过Ajax提交后台
                    datagrid.datagrid("endEdit", editRow);
                }
                }, '-',
                { text: '取消编辑', iconCls: 'icon-redo', handler: function () {
                    //取消当前编辑行把当前编辑行罢undefined回滚改变的数据,取消选择的行
                    editRow = undefined;
                    datagrid.datagrid("rejectChanges");
                    datagrid.datagrid("unselectAll");
                }
                }, '-'],
               onAfterEdit: function (rowIndex, rowData, changes) {
                   //endEdit该方法触发此事件
                   console.info(rowData);
                   editRow = undefined;
               },
               onDblClickRow: function (rowIndex, rowData) {
               //双击开启编辑行
                   if (editRow != undefined) {
                       datagrid.datagrid("endEdit", editRow);
                   }
                   if (editRow == undefined) {
                       datagrid.datagrid("beginEdit", rowIndex);
                       editRow = rowIndex;
                   }
               },
	        loadMsg: '数据加载中...',
		    mode : 'remote',
		    delay : 500,
		    fit:false,
	        columns:[[
			{field:'remark',title:'摘要',width:242,editor: { type: 'text', options: { required: true } }},
			{field:'kmname',title:'科目名称',width:242,editor: { type: 'text', options: { required: true } }},
			{field:'mdf',title:'借方',width:242},
		 	{field:'mcf',title:'贷方',width:242}
		   ]]
		});	 
});

/*   $(function(){
	var wheight=$(window).height()/4;
	$("#ttt").css("margin-top",wheight);
}) */
</script>
</head>
<body>
<a href="http://localhost:8080/unionx_uf/views/createBill3.jsp">关闭</a>

<div id="ttt" align="center">


<table id="bt">
   <tr>
   <td>凭证类别：<input type="text" id="jzpz" value="记"></td>
   <td>凭证编号：<input type="text" id="pzbh"></td>
   <td>账单日期：<input type="text" id="zdrq"></td>
   <td>附单据数：<input type="text" id="djs"></td>
   </tr>
</table>

<table id="tt"></table>
<table id="wb">
   <tr>
   <td>制单人：<input type="text" id="zdren"></td>
   </tr>
</table>

<input id="i1" type="hidden" value="<%=request.getParameter("lsh") %>"/>
</div>
</body>
</html>